package cn.train.controler;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.train.service.EditTrainServices;

@WebServlet("/EditTrainDelServlet")
public class EditTrainDelServlet extends HttpServlet {
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		String id=req.getParameter("id");
		int m= Integer.parseInt(id);
		EditTrainServices ets=new EditTrainServices();
		resp.setContentType("text/html;charSet=utf-8");
		PrintWriter out =resp.getWriter();
		int n=ets.del(m);
		if(n>0){
			out.print("<script>alert('删除成功');location.href='EditTrainServlet'</script>;");
		}else{
			out.print("<script>alert('删除失败');location.href='EditTrainServlet'</script>;");
		}
	}

	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doGet(req, resp);
	}
}
